﻿<Page
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
	  x:Class="MovieRental_Presentation.Movies" 
      d:DesignWidth="1024" d:DesignHeight="600"
      mc:Ignorable="d"
      WindowTitle="Movie Rental"
	  MinWidth="900"
	  MinHeight="500" 
      ShowsNavigationUI="False">

	<Grid Background="{StaticResource backgroundBrush}">
    	<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="250"/>
		</Grid.ColumnDefinitions>
		<Border BorderThickness="{StaticResource borderThickness}" Padding="{StaticResource borderPadding}" Margin="8" CornerRadius="{StaticResource borderCornerRadius}" BorderBrush="{StaticResource borderBrush}" Grid.Column="1">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="210"/>
					<RowDefinition/>
				</Grid.RowDefinitions>
				<StackPanel Grid.Row="0">
					<Label Content="Menu" HorizontalAlignment="Center" Style="{StaticResource MenuLabelStyle}"/>
					<Button x:Name="dashboardButton" Content="Dashboard" Height="40" Margin="0,8" Click="dashboardButton_Click" Template="{StaticResource MenuButtonTemplate}"/>
					<Button x:Name="customersButton" Content="Customers" Height="40" Margin="0,8" Template="{StaticResource MenuButtonTemplate}" Click="customersButton_Click"/>
					<Button x:Name="statisticsButton" Content="Statistics" Height="40" Margin="0,8" Template="{StaticResource MenuButtonTemplate}" Click="statisticsButton_Click"/>
				</StackPanel>
				<Frame Content="" Grid.Row="1" Margin="0" Source="/MovieRental.Presentation;component/Cart.xaml" NavigationUIVisibility="Hidden"/>
			</Grid>
		</Border>
		<Border BorderBrush="{StaticResource borderBrush}" BorderThickness="{StaticResource borderThickness}" Margin="8" Padding="{StaticResource borderPadding}" CornerRadius="{StaticResource borderCornerRadius}">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto"/>
					<RowDefinition/>
				</Grid.RowDefinitions>
				<Label Content="Movies" Margin="0" d:LayoutOverrides="Height" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource MenuLabelStyle}"/>
				<Button x:Name="backButton" Content="Back" HorizontalAlignment="Left" Width="60" Margin="8,8,0,0" Grid.RowSpan="2" Height="60" VerticalAlignment="Top" Click="backButton_Click" />
				<Grid Grid.Row="1">
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="0.7*"/>
						<RowDefinition Height="Auto"/>			
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition Width="*"/>
					</Grid.ColumnDefinitions>
					<StackPanel x:Name="selectedCustomerPanel" Grid.Column="0" Grid.Row="1" Margin="8">
						<Button x:Name="addButton" Content="Add" Height="50" Margin="0,0,0,8" Width="50" Click="addButton_Click"/>
						<Button x:Name="deleteButton" Content="Delete" Height="50" Margin="0,0,0,8" Width="50"  Visibility="{Binding ElementName=moviesDataGrid, Path=SelectedIndex, Converter={StaticResource indexVisibilityConverter}}" Click="deleteButton_Click" />
						<Button x:Name="editButton" Content="Edit" Height="50" Margin="0,0,0,8" Width="50" Click="editButton_Click" Visibility="{Binding ElementName=moviesDataGrid, Path=SelectedIndex, Converter={StaticResource indexVisibilityConverter}}" />
					</StackPanel>
					<TextBox x:Name="searchBox" Text="{Binding Path=SearchString, Mode=OneWayToSource}" BorderBrush="{StaticResource borderBrush}" BorderThickness="1" Background="{StaticResource backgroundBrush}" Foreground="{StaticResource inputBoxBrush}" Grid.Row="0" Grid.Column="1" Margin="8" KeyUp="searchBox_KeyUp" />
					<Expander Grid.Row="2" Grid.Column="1">
                        <Expander.Header>
                            <TextBlock Text="Top-10 and Bottom-10 Movies" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource borderBrush}" Margin="0"/>
						</Expander.Header>
						<Grid MinHeight="150">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
							<DataGrid Grid.Column="0" Margin="8" ItemsSource="{Binding TopMovies}" AutoGenerateColumns="False">
								<DataGrid.Columns>
									<DataGridTextColumn Header="Title" Binding="{Binding Entity.Title}" Width="*"/>
									<DataGridTextColumn Header="Loans" Binding="{Binding LoansCount}" Width="*"/>
								</DataGrid.Columns>
							</DataGrid>
                            <DataGrid Grid.Column="1" Margin="8" ItemsSource="{Binding BottomMovies}" AutoGenerateColumns="False">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="Title" Binding="{Binding Entity.Title}" Width="*"/>
                                    <DataGridTextColumn Header="Loans" Binding="{Binding LoansCount}" Width="*"/>
                                </DataGrid.Columns>
                            </DataGrid>
                        </Grid>
					</Expander>
                    <DataGrid Grid.Column="1" Margin="8" Grid.Row="1" Name="moviesDataGrid" ItemsSource="{Binding MoviesList}" IsReadOnly="True" MouseDoubleClick="moviesDataGrid_MouseDoubleClick" AutoGenerateColumns="False">
						<DataGrid.Columns>
							<DataGridTextColumn Header="Title" Width="*" Binding="{Binding Entity.Title}" />
							<DataGridTextColumn Header="IMDB Rating" Width="*" Binding="{Binding Path=Entity.ImdbRating}"/>
							<DataGridTextColumn Header="Web Page" Width="*" Binding="{Binding Entity.WebPage}"/>
						</DataGrid.Columns>
					</DataGrid>
				</Grid>
				
			</Grid>
		</Border>
	</Grid>
</Page>